package com.trmq.config;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/3/5  10:52
 * 描述:
 */
@Component
public class MyConfirmCallBack implements RabbitTemplate.ConfirmCallback {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void init(){
        rabbitTemplate.setConfirmCallback(this);
    }

    @Override
    public void confirm(CorrelationData correlationData, boolean b, String s) {

        if(b){
            System.out.println("=========ok========");
        }else{
            throw new RuntimeException("更新发送rabbitMQ失败");
        }
    }
}
